//
//  RBGradientView.m
//  RBDemoProj
//
//  Created by Lan on 2019/2/15.
//  Copyright © 2019年 SummerTea. All rights reserved.
//

#import "RBGradientView.h"
#import "UIView+RBAdd.h"

@interface RBGradientView()

@property(nonatomic, strong) CAGradientLayer *gradientLayer;

@end

@implementation RBGradientView

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.gradientLayer.frame = self.bounds;
}

+ (instancetype)gradientViewWithColors:(NSArray *)colors locations:(NSArray *)locations vertical:(BOOL)vertical
{
    CAGradientLayer *layer = [UIView gradientLayerWithColors:colors locations:locations vertical:vertical];
    RBGradientView *view = [RBGradientView new];
    view.backgroundColor = [UIColor clearColor];
    view.gradientLayer = layer;
    [view.layer addSublayer:layer];
    return view;
}

@end
